<?php
// *** Tangra (Application Framework and Tools for PHP)
// $Id$
//

require_once($WSC->get_site_inc_dir().'modules/json_encdec_interface/i_json_encdec.class.php');


class JSON_EncDec_PHP extends Tangra_Class implements I_JSON_EncDec {
    public static function encode($value_to_encode, $cycle_check = false) {
        if (function_exists('json_encode')) {
            $ret = json_encode($value_to_encode);
        } else {
        	throw new Tangra_Module_Exception('JSON extension is not compiled into PHP.');
        }

		return $ret;
    }


    public static function decode($encoded_value, $object_decode_type = true) {
        if (function_exists('json_decode')) {
            $ret = json_decode($encoded_value, $object_decode_type);
        } else {
        	throw new Tangra_Module_Exception('JSON extension is not compiled into PHP.');
        }

		return $ret;
    }
}



